package com.briup.app02.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app02.bean.BaseFile;
import com.briup.app02.service.IBaseFileService;
import com.briup.app02.utils.Message;
import com.briup.app02.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/basefile")
@Api(description = "附件表相关接口")
@Validated
public class BaseFileController {

	@Autowired
	private IBaseFileService basefileService;
	
	@GetMapping("query")
	@ApiOperation("查询所有附件表信息")
	public Message query(String name){
		List<BaseFile> list = basefileService.query(name);
		return MessageUtil.success(list);
	}
	
	@PostMapping("saveOrUpdate")
	@ApiOperation(value="保存或更新")
	@ApiImplicitParams({
		@ApiImplicitParam(name="id",value = "主键",paramType = "form"),
        @ApiImplicitParam(name="fileName",value = "文件名称",paramType = "form",required = true),
        @ApiImplicitParam(name="groupName",value = "组名",paramType = "form"),
        @ApiImplicitParam(name="uploadTime",value = "上传时间",paramType = "form"),
        @ApiImplicitParam(name="extName",value = "名字",paramType = "form"),
        @ApiImplicitParam(name="fileSize",value = "文件大小",paramType = "form"),
        @ApiImplicitParam(name="fileType",value = "文件类型",paramType = "form"),
	})
	public Message saveOrUpdate(BaseFile basefile) {
		basefileService.saveOrUpdate(basefile);
		return MessageUtil.success("操作成功");
	}
	
	@DeleteMapping("deleteById")
	@ApiOperation("根据id删除附件表信息")
	@ApiImplicitParams({
		@ApiImplicitParam(name="id",value = "附件表id",dataType = "long",paramType = "query",required = true)
	})
	public String deleteById(String id) {
		basefileService.deleteById(id);
		return "删除成功";
	}
}
